home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / makeindex / scanid.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-26  |  3.1 KB  |  142 lines

  1. /*
  2.  *
  3.  * Copyright (C) 1987     Pehong Chen    (phc@renoir.berkeley.edu)
  4.  * Computer Science Division
  5.  * University of California, Berkeley
  6.  *
  7.  */
  8.  
  9. #define    IS_COMPOSITOR         (strncmp(&no[i], page_comp, comp_len) == 0)
  10.  
  11. #define    ROMAN_I            'I'
  12. #define    ROMAN_V            'V'
  13. #define    ROMAN_X            'X'
  14. #define    ROMAN_L            'L'
  15. #define    ROMAN_C            'C'
  16. #define    ROMAN_D            'D'
  17. #define    ROMAN_M            'M'
  18.  
  19. #define    ROMAN_i            'i'
  20. #define    ROMAN_v            'v'
  21. #define    ROMAN_x            'x'
  22. #define    ROMAN_l            'l'
  23. #define    ROMAN_c            'c'
  24. #define    ROMAN_d            'd'
  25. #define    ROMAN_m            'm'
  26.  
  27. #define    VAL_I            1
  28. #define    VAL_V            5
  29. #define    VAL_X            10
  30. #define    VAL_L            50
  31. #define    VAL_C            100
  32. #define    VAL_D            500
  33. #define    VAL_M            1000
  34.  
  35. #define    ROMAN_LOWER_VAL(C) \
  36.     ((C == ROMAN_i) ? VAL_I : \
  37.      (C == ROMAN_v) ? VAL_V : \
  38.      (C == ROMAN_x) ? VAL_X : \
  39.      (C == ROMAN_l) ? VAL_L : \
  40.      (C == ROMAN_c) ? VAL_C : \
  41.      (C == ROMAN_d) ? VAL_D : \
  42.      (C == ROMAN_m) ? VAL_M : 0)
  43.  
  44. #define    ROMAN_UPPER_VAL(C) \
  45.     ((C == ROMAN_I) ? VAL_I : \
  46.      (C == ROMAN_V) ? VAL_V : \
  47.      (C == ROMAN_X) ? VAL_X : \
  48.      (C == ROMAN_L) ? VAL_L : \
  49.      (C == ROMAN_C) ? VAL_C : \
  50.      (C == ROMAN_D) ? VAL_D : \
  51.      (C == ROMAN_M) ? VAL_M : 0)
  52.  
  53. #define IS_ROMAN_LOWER(C) \
  54.     ((C == ROMAN_i) || (C == ROMAN_v) || (C == ROMAN_x) || \
  55.      (C == ROMAN_l) || (C == ROMAN_c) || (C == ROMAN_d) || (C == ROMAN_m))
  56.  
  57. #define IS_ROMAN_UPPER(C) \
  58.     ((C == ROMAN_I) || (C == ROMAN_V) || (C == ROMAN_X) || \
  59.      (C == ROMAN_L) || (C == ROMAN_C) || (C == ROMAN_D) || (C == ROMAN_M))
  60.  
  61. #define ALPHA_VAL(C) \
  62.     ((('A' <= C) && (C <= 'Z')) ? C - 65 : \
  63.      (('a' <= C) && (C <= 'z')) ? C - 97 : 0)
  64.  
  65. #define IS_ALPHA_LOWER(C) \
  66.     (('a' <= C) && (C <= 'z'))
  67.  
  68. #define IS_ALPHA_UPPER(C) \
  69.     (('A' <= C) && (C <= 'Z'))
  70.  
  71. #define    IDX_SKIPLINE { \
  72.     int tmp; \
  73.     while ((tmp = GET_CHAR(idx_fp)) != LFD) \
  74.         if (tmp == EOF) \
  75.             break; \
  76.     idx_lc++; \
  77.     arg_count = -1; \
  78. }
  79.  
  80. #define NULL_RTN { \
  81.     IDX_ERROR("Illegal null field.\n", NULL); \
  82.     return (FALSE); \
  83. }
  84.  
  85. #if    KCC_20
  86. /* KCC preprocessor bug collapses multiple blanks to single blank */
  87. #define IDX_ERROR(F, D) { \
  88.     if (idx_dot) { \
  89.         fprintf(ilg_fp, "\n"); \
  90.         idx_dot = FALSE; \
  91.     } \
  92.     fprintf(ilg_fp, "!! Input index error (file = %s, line = %d):\n\040\040 -- ", \
  93.             idx_fn, idx_lc); \
  94.     fprintf(ilg_fp, F, D); \
  95.     idx_ec++; \
  96. }
  97.  
  98. #define IDX_ERROR2(F, D1, D2) { \
  99.     if (idx_dot) { \
  100.         fprintf(ilg_fp, "\n"); \
  101.         idx_dot = FALSE; \
  102.     } \
  103.     fprintf(ilg_fp, "!! Input index error (file = %s, line = %d):\n\040\040 -- ", \
  104.             idx_fn, idx_lc); \
  105.     fprintf(ilg_fp, F, D1, D2); \
  106.     idx_ec++; \
  107. }
  108. #else
  109. #define IDX_ERROR(F, D) { \
  110.     if (idx_dot) { \
  111.         fprintf(ilg_fp, "\n"); \
  112.         idx_dot = FALSE; \
  113.     } \
  114.     fprintf(ilg_fp, "!! Input index error (file = %s, line = %d):\n   -- ", \
  115.             idx_fn, idx_lc); \
  116.     fprintf(ilg_fp, F, D); \
  117.     idx_ec++; \
  118. }
  119.  
  120. #define IDX_ERROR2(F, D1, D2) { \
  121.     if (idx_dot) { \
  122.         fprintf(ilg_fp, "\n"); \
  123.         idx_dot = FALSE; \
  124.     } \
  125.     fprintf(ilg_fp, "!! Input index error (file = %s, line = %d):\n   -- ", \
  126.             idx_fn, idx_lc); \
  127.     fprintf(ilg_fp, F, D1, D2); \
  128.     idx_ec++; \
  129. }
  130. #endif
  131.  
  132.  
  133. #define    ENTER(V) { \
  134.     if (*count >= PAGEFIELD_MAX) { \
  135.         IDX_ERROR2("Page number %s has too many fields (max. %d).", \
  136.                no, PAGEFIELD_MAX); \
  137.         return (FALSE); \
  138.     } \
  139.     npg[*count] = (V); \
  140.     ++*count; \
  141. }
  142.